<?php
!defined('P_W') && exit('Forbidden');
require_once MODE . '/base/basehelper.php';

/**
 * 开通经纪人helper
 * @author bingbing.renbb
 *
 */
class PW_CheckinHelper extends BaseHelper{
	
	/**
	 * 输出申请csv文件
	 */
	function export() {
		global $timestamp;
		$filename = $this->_dataConvert("房产经纪人（中介）开通申请表.csv");
		header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $timestamp + 86400) . ' GMT');
		header('Expires: ' . gmdate('D, d M Y H:i:s', $timestamp + 86400) . ' GMT');
		header('Cache-control: max-age=86400');
		header('Content-Encoding: utf-8');
		header("Content-Disposition: attachment; filename=\"{$filename}\"");
		header("Content-type: application/csv");
		header("Content-Transfer-Encoding: binary");
		$_exportData = array('用户名', '姓名', '服务商圈', '所属公司', '工作地址', '手机号码', '固定电话', '身份证号码', '支付宝账号', '其他证件');
		echo $this->_dataConvert(implode(',', $_exportData));
	}
	
	/**
	 * 数据编码转换
 	 * @param string $data 待转换数据
 	 * @param string $to_encoding 目标编码
	 * @return string 转换后的数据
 	 */
	function _dataConvert($data, $to_encoding = 'gbk') {
		global $db_charset;
		if ($db_charset == $to_encoding) return $data;
		if (function_exists('mb_convert_encoding')) {
			return mb_convert_encoding($data, $to_encoding, $db_charset);
		} else {
			L::loadClass('Chinese', 'utility/lang', false);
			$chs = new Chinese($db_charset, $to_encoding);
			return $chs->Convert($data);
		}
	}
}
?>